#region Using

using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration.Provider;
using CoyoEden;
using CoyoEden.Models;
using CoyoEden.Services;

#endregion

namespace CoyoEden.Providers
{
	/// <summary>
	/// A base class for all custom providers to inherit from.
	/// </summary>
	public abstract class PortalProvider : ProviderBase,IPortalServices
	{
        #region IAlbumService Members

        public abstract Album SelectAlbum(int id);

        public abstract void InsertAlbum(Album album);

        public abstract void UpdateAlbum(Album album);

        public abstract void DeleteAlbum(Album album);

        public abstract List<Album> FillAlbums();

        #endregion

        #region IAuthorProfileService Members

        public abstract AuthorProfile SelectProfile(string id);

        public abstract void InsertProfile(AuthorProfile profile);

        public abstract void UpdateProfile(AuthorProfile profile);

        public abstract void DeleteProfile(AuthorProfile profile);

        public abstract List<AuthorProfile> FillProfiles();

        #endregion

        #region ICategoryService Members

        public abstract Category SelectCategory(int id);

        public abstract void InsertCategory(Category category);

        public abstract void UpdateCategory(Category category);

        public abstract void DeleteCategory(Category category);

        public abstract List<Category> FillCategories();

        #endregion

        #region ICommunityService Members

        public abstract Community SelectCommunity(int id);

        public abstract void InsertCommunity(Community item);

        public abstract void UpdateCommunity(Community item);

        public abstract void DeleteCommunity(Community item);

        public abstract List<Community> FillCommunities();

        #endregion

        #region IDataStoreService Members

        public abstract object LoadFromDataStore(CoyoEden.DataStore.ExtensionType exType, string exId);

        public abstract void SaveToDataStore(CoyoEden.DataStore.ExtensionType exType, string exId, object settings);

        public abstract void RemoveFromDataStore(CoyoEden.DataStore.ExtensionType exType, string exId);
        #endregion

        #region IOtherService Members

        public abstract string StorageLocation();

        #endregion

        #region IPageService Members

        public abstract Page SelectPage(int id);

        public abstract void InsertPage(Page page);

        public abstract void UpdatePage(Page page);

        public abstract void DeletePage(Page page);

        public abstract List<Page> FillPages();

        #endregion

        #region IPingService Members

        public abstract StringCollection LoadPingServices();

        public abstract void SavePingServices(StringCollection services);

        #endregion

        #region IPortalFileService Members

        public abstract PortalFile SelectPortalFile(int id);

        public abstract void InsertPortalFile(PortalFile item);

        public abstract void UpdatePortalFile(PortalFile item);

        public abstract void DeletePortalFile(PortalFile item);

        public abstract List<PortalFile> FillPortalFiles();

        #endregion

        #region IPostService Members

        public abstract Post SelectPost(int id);

        public abstract void InsertPost(Post post);

        public abstract void UpdatePost(Post post);

        public abstract void DeletePost(Post post);

        public abstract List<Post> FillPosts();

        #endregion

        #region IRateService Members

        public abstract Rate SelectRate(int id);

        public abstract void InsertRate(Rate item);

        public abstract void UpdateRate(Rate item);

        public abstract void DeleteRate(Rate item);

        public abstract void DeleteRates(List<Rate> items);

        public abstract List<Rate> FillRates();

        public abstract void InsertRates(List<Rate> items);

        public abstract void UpdateRates(List<Rate> items);

        #endregion

        #region ISettingService Members

        public abstract StringDictionary LoadSettings();

        public abstract void SaveSettings(StringDictionary settings);

        #endregion

        #region IStopWordService Members

        public abstract StringCollection LoadStopWords();

        #endregion

        #region ITopicService Members

        public abstract  Topic SelectTopic(int id);

        public abstract void InsertTopic(Topic item);

        public abstract void UpdateTopic(Topic item);

        public abstract void DeleteTopic(Topic item);

        public abstract List<Topic> FillTopics();

        #endregion

        #region IVoteService Members

        public abstract Vote SelectVote(int id);

        public abstract void InsertVote(Vote item);

        public abstract void UpdateVote(Vote item);

        public abstract void DeleteVote(Vote item);

        public abstract List<Vote> FillVotes();

        #endregion
    }

	/// <summary>
	/// A collection of all registered providers.
	/// </summary>
	public class PortalProviderCollection : ProviderCollection
	{
		/// <summary>
		/// Gets a provider by its name.
		/// </summary>
		public new PortalProvider this[string name]
		{
			get { return (PortalProvider)base[name]; }
		}

		/// <summary>
		/// Add a provider to the collection.
		/// </summary>
		public override void Add(ProviderBase provider)
		{
			if (provider == null)
				throw new ArgumentNullException("provider");

			if (!(provider is PortalProvider))
				throw new ArgumentException
						("Invalid provider type", "provider");

			base.Add(provider);
		}
	}

}
